import maya.cmds as mc


import tools_Persional.LZ_Tools.LZ_Tools.check_tools.LZ_cheeckTools.LZ_operations.LZ_core  as LZ_core
reload(LZ_core)

class LZ_rig_check( LZ_core.LZ_core ):
    def __init__(self):
        pass
        
    def checkControllerAttributesWithInput(self, *args, **kw):
        """ 
        @brief List controllers whose animatable attributes have an input connection.
        @return : Set
        
        ARGS :
                @param assetRoot - String - Asset root node.
        """
        
        # list nodes which attributes have input.
        issues = []
        
        #controllers = core.getCtrlList(assetRoot)
        
        controllers = mc.ls('*_ctrl')
        
        if not len(controllers) == 0 :
            for controller in controllers:
                if mc.objExists('%s.allowPublishWithConnections' % controller) is True:
                    continue
        
                attrs = self.listStorableAttrs( node = controller , shortName=True, noCompound=True)
                if not attrs is None :
                    for attr in attrs:
                        input = []
                        input = mc.listConnections("%s.%s" %(controller, attr), s=True, d=False)
                        if input:
                            issues.append("%s.%s" %(controller, attr))
        
        
        if len(issues) == 0 :
            return self.checkResult(allowPublish=True, msg="Everything is OK")
        else :
            return self.checkResult(allowPublish=False, msg="Those animatable attributes have an input connection", nodes=issues)
        
    #checkControllerAttributesWithInput.modifiedScene = False
    #checkControllerAttributesWithInput.uiName = 'Check Controllers Animatable Attributes Input'
    #checkControllerAttributesWithInput.revision = "$Revision: 68809 $".split()[1]
            